package com.hu.service;

import com.hu.bookstorecommon.entity.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class userServiceImpl implements userService{
    @Autowired
    private RestTemplate restTemplate;


   @Value("${user.rest.url}")
    private String userUrl;
    @Override
    public user login(String username) {

        String url = String.format("%s?username=%s",userUrl,username);
        //System.out.println(url);
        return restTemplate.getForObject(url,user.class);

    }



    @Override
    public Integer userRegister(user user) {

        return restTemplate.postForObject(userUrl,user,Integer.class);
    }
}
